package oa.user.websercvice.client;



import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

/**
 * XMLGregorianCalendar类型和Date类型之间的相互转换
 * @author Xin
 * 2010-06-12
 */

public class DateUtils {

    public static XMLGregorianCalendar convertToXMLGregorianCalendar(Date date) {

        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(date);
        XMLGregorianCalendar gc = null;
        try {
            gc = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
        } catch (Exception e) {

             e.printStackTrace();
        }
        return gc;
    }
 
     public static Date convertToDate(XMLGregorianCalendar cal){
         GregorianCalendar ca = cal.toGregorianCalendar();
         return ca.getTime();
     }
 
  
}



